Socket
Socket
Sign inDemoInstall

chrome-tab

Package Overview
Dependencies
5
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    chrome-tab

Sugar for Chrome's remote debugging protocol


Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Install size
354 kB
Created
Weekly downloads
 

Readme

Source

chrome-tab

Sugar for Chrome's remote debugging protocol.

Why

Phantom's cool but it's hard to get your hands on a binary. Also why not just use a real browser?

How

JSON-RPC over a WebSocket. This is the same interface devtools uses to talk to Chrome - check out the API here.

Example

var Tab = require('./')
var Emitter = require('events')

var tab = new Tab()

process.on('SIGINT', () => {
  tab.close(process.exit)
})

tab.open(err => {
  if (err) throw err

  var events = new Emitter()

  // use rpc-engine's default method to catch any incoming notifications
  tab.defaultMethod = (name, params) => {
    events.emit(name, params)
  }

  // open the Page and Network notification firehoses
  tab.call('Page.enable', err => {})
  tab.call('Network.enable', err => {})

  // wait for Page.frameNavigated
  events.once('Page.frameNavigated', (params) => {
    console.log('Page.frameNavigated', params)

    // use Runtime.execute to run some js to dump the document's outerHTML
    tab.call('Runtime.evaluate', {
      expression: 'document.documentElement.outerHTML',
      returnByValue: true
    }, (err, result) => {
      console.log(result.result.value)
    })
  })

  tab.call('Page.navigate', {
    url: 'https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/websocket-server'
  }, err => {})
})

License

Public domain

FAQs

Last updated on 09 Dec 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc